home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0195.ZIP / EQUIPMNT.LIB < prev    next >
Text File  |  1984-12-20  |  3KB  |  71 lines

  1. {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
  2. The purchaser of these procedures and functions may include them in COMPILED
  3. programs freely, but may not sell or give away the source text.
  4.  
  5.      The function Equipment returns the number of items of
  6.      the specified type currently attached.
  7.        "P" : Printers (0 to 3)
  8.        "G" : Game port (0 or 1)
  9.        "R" : RS232 port (0 to 7?)
  10.        "D" : Diskette drives (0 to 4)
  11.        "V" : code for initial video mode
  12.        "M" : amount of raM on motherboard (not much use!)
  13.  
  14.    NOTE that any program that INCLUDEs this file MUST also include the
  15.    type declarations contained in REGPACK.TYP.
  16.  
  17. }
  18. function Equipment(which : char):byte;
  19. var
  20.   registers : regpack;
  21.   result    : integer;
  22.   temp : byte;
  23. begin
  24.   INTR($11,registers);
  25.   result := registers.AX;
  26.       {NOTE: from the IBM PC Technical Reference Manual we glean
  27.       the following about the makeup of "result".  Its 16 bits are
  28.       numbered from 15 down to 0 and have these meanings:
  29.          15,14 : # of printers
  30.             13 : not used
  31.             12 : 1 = Game I/O exists
  32.           11-9 : # of RS232 ports
  33.              8 : not used
  34.            7,6 : IF bit 0 is set, these two show one less than
  35.                  the number of drives.  (00 = 1, 01 = 2, 10 = 3, 11 = 4)
  36.            5,4 : initial video mode:
  37.                     00 : not used
  38.                     01 : 40x25 BW using color card
  39.                     10 : 80x25 BW using color card
  40.                     11 : 80x25 BW using BW card
  41.            3,2 : planar board RAM -- 00 = 16K, 01 = 32K, 10 = 48K, 11 = 64K
  42.              1 : not used
  43.              0 : if set to 1, there are diskette drives
  44.  
  45.        If the bits we want are the X's in this picture -- "nnnnnXXnnnnnnnnn",
  46.        to get the number represented by those bits, we SHift Right until the
  47.        leftmost X is in the highest position ( "XXnnnnnnnnn00000" ) and
  48.        then SHift Left until the rightmost X is in the lowest position
  49.        ("00000000000000XX").
  50. }
  51.  
  52.   case UpCase(which) of
  53.     'P': temp := result shr 14;
  54.     'G': temp := (result shl 3) shr 15;
  55.     'R': temp := (result shl 4) shr 13;
  56.     'D': if result and 1 = 0 then
  57.            temp := 0
  58.          else temp := ((result shl 8) shr 14) + 1;
  59.     'V': temp := (result shl 10 ) shr 14;
  60.     'M': begin
  61.            temp := ((result shl 12 ) shr 14);
  62.            case temp of
  63.              0: temp := 16;
  64.              1: temp := 32;
  65.              2: temp := 48;
  66.              3: temp := 64;
  67.            end;
  68.          end;
  69.   end;
  70.   Equipment := temp;
  71. end;